package 异常处理;

public class Demo3 {

    public static void a(int week) throws Exception {
        if (week > 7) {
            Exception exception = new Exception("星期只有1-7");
            throw exception;
        }
        System.out.println("星期" + week);
    }

    public static void b(int week) throws Exception {
        a(week);
    }

    public static void c(int week) {
        try {
            b(week);
        } catch (Exception e) {
            System.out.println("出现了异常!\n" + e.getMessage());
        }
    }


    public static void main(String[] args) {
        c(2);
    }
}
